Skip to content

Add new implementation of math library (libmcs), remove math library dependency from strtod.c#460

Open
ayoopierre wants to merge 3 commits intomasterfrom
ayopierre/add_libcsm
Open

Add new implementation of math library (libmcs), remove math library dependency from strtod.c#460
ayoopierre wants to merge 3 commits intomasterfrom
ayopierre/add_libcsm

Conversation

@ayoopierre
Copy link
Copy Markdown

Add new implementation of math library (libmcs v1.3.0).

Description

Add new implementation of math library (libmcs), move libphoenix implementation of math library, remove dependency of strtod.c on math library. Current configuration will fail to compile on ia32 because of patches on micropython applied before compilation.

Motivation and Context

Adding complete math library implementation with extensions for critical applications

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (tested on all targets, fails on ia32 with libmcs version due to patches applied on micropython).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @ayoopierre, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the project's mathematical capabilities by integrating a new, robust math library, 'libmcs'. This change not only broadens the range of supported mathematical functions and improves compliance with industry standards but also introduces a more modular and configurable approach to managing math implementations. The existing 'libphoenix' math code has been reorganized to coexist, providing flexibility for different project requirements and hardware constraints.

Highlights

  • New Math Library Integration: Integrated a new, comprehensive math library, 'libmcs' (version 1.3.0), designed for critical applications and offering broader C99 compliance.
  • Modular Math Library Structure: Refactored the math library inclusion by moving the existing 'libphoenix' math implementation to a dedicated 'libm/phoenix' directory and introducing a new 'libm' top-level directory to house both implementations.
  • Configurable Math Implementation: Introduced a new 'libm/Makefile' and 'libm/libmcs/configure' script, allowing users to select between 'libmcs' and 'libphoenix' implementations, enable/disable complex number support, and configure denormal handling (DAZ/FTZ) based on target FPU capabilities.
  • Dependency Removal: Eliminated the direct dependency of 'strtod.c' on the math library, addressing potential compilation issues on specific architectures like ia32 due to micropython patches.
  • Enhanced Functionality and Standards Compliance: The new 'libmcs' library provides extensive implementations for double and float precision math functions, complex number operations, and various utility macros, aligning with IEEE-754, C18, POSIX, and MISRA C standards.
Changelog
  • Makefile
    • Updated the math library include path from 'math/Makefile' to 'libm/Makefile'.
    • Modified the 'install-headers' target to also copy headers from 'libm/libmcs/libm/include'.
  • include/complex.h
    • Removed the old 'complex.h' header file.
  • include/math.h
    • Removed the old 'math.h' header file.
  • include/math/consts.h
    • Removed the old 'math/consts.h' header file.
  • libm/Makefile
    • Added a new Makefile to manage the 'libm' directory, including conditional compilation for 'libmcs' and 'libphoenix' implementations, complex number support, and DAZ options.
  • libm/README.md
    • Added a README file detailing the new math library structure, usage instructions, and information about 'libmcs' and 'libphoenix' implementations.
  • libm/libm/phoenix/common.c
    • Renamed 'math/common.c' to 'libm/phoenix/common.c'.
  • libm/libmcs/.clang-format
    • Added clang-format configuration file for libmcs.
  • libm/libmcs/.gitattributes
    • Added gitattributes file for libmcs, including merge driver settings for ChangeLog files.
  • libm/libmcs/.gitignore
    • Added gitignore file for libmcs, specifying files and directories to be ignored.
  • libm/libmcs/.gitlab-ci.yml
    • Added GitLab CI/CD configuration for libmcs, defining stages for setup, checks, documentation generation, and pages deployment.
  • libm/libmcs/CITATION.cff
    • Added CITATION.cff file for libmcs, providing citation metadata for the software.
  • libm/libmcs/CONTRIBUTING.md
    • Added CONTRIBUTING.md file for libmcs, outlining guidelines for reporting bugs, suggesting enhancements, and submitting pull requests.
  • libm/libmcs/COPYING.md
    • Added COPYING.md file for libmcs, specifying the licensing conditions.
  • libm/libmcs/CREDITS.md
    • Added CREDITS.md file for libmcs, listing contributors to the project.
  • libm/libmcs/Dockerfile
    • Added Dockerfile for libmcs, setting up a Python environment with necessary tools for building and testing.
  • libm/libmcs/LICENSES/GTDGmbH.md
    • Added GTDGmbH license file for libmcs.
  • libm/libmcs/LICENSES/NetBSD.md
    • Added NetBSD license file for libmcs.
  • libm/libmcs/LICENSES/PublicDomain.md
    • Added PublicDomain license file for libmcs.
  • libm/libmcs/LICENSES/RedHat.md
    • Added RedHat license file for libmcs.
  • libm/libmcs/LICENSES/RichFelker.md
    • Added RichFelker license file for libmcs.
  • libm/libmcs/LICENSES/SunMicrosystems.md
    • Added SunMicrosystems license file for libmcs.
  • libm/libmcs/Makefile.in
    • Added Makefile.in for libmcs, defining build rules and source files for the new math library.
  • libm/libmcs/README.md
    • Added README.md for libmcs, providing an overview, getting started guide, and contribution instructions.
  • libm/libmcs/configure
    • Added configure script for libmcs, enabling interactive and flag-based configuration of build options.
  • libm/libmcs/libm/common/cmplx.c
    • Added source file for CMPLX macros documentation.
  • libm/libmcs/libm/common/fenv.c
    • Added source file for fenv functions (stubs with error returns).
  • libm/libmcs/libm/common/isfinite.c
    • Added source file for isfinite macro documentation.
  • libm/libmcs/libm/common/isgreater.c
    • Added source file for isgreater macro documentation.
  • libm/libmcs/libm/common/isgreaterequal.c
    • Added source file for isgreaterequal macro documentation.
  • libm/libmcs/libm/common/isinf.c
    • Added source file for isinf macro documentation.
  • libm/libmcs/libm/common/isless.c
    • Added source file for isless macro documentation.
  • libm/libmcs/libm/common/islessequal.c
    • Added source file for islessequal macro documentation.
  • libm/libmcs/libm/common/islessgreater.c
    • Added source file for islessgreater macro documentation.
  • libm/libmcs/libm/common/isnan.c
    • Added source file for isnan macro documentation.
  • libm/libmcs/libm/common/isnormal.c
    • Added source file for isnormal macro documentation.
  • libm/libmcs/libm/common/isunordered.c
    • Added source file for isunordered macro documentation.
  • libm/libmcs/libm/common/signgam.c
    • Added source file for signgam global variable implementation.
  • libm/libmcs/libm/common/tools.c
    • Added source file for common floating-point utility constants.
  • libm/libmcs/libm/common/tools.h
    • Added header file for common floating-point utility macros and inline functions.
  • libm/libmcs/libm/complexd/cabsd.c
    • Added double precision complex absolute value function.
  • libm/libmcs/libm/complexd/cacosd.c
    • Added double precision complex arc cosine function.
  • libm/libmcs/libm/complexd/cacoshd.c
    • Added double precision complex hyperbolic arc cosine function.
  • libm/libmcs/libm/complexd/cargd.c
    • Added double precision complex argument function.
  • libm/libmcs/libm/complexd/casind.c
    • Added double precision complex arc sine function.
  • libm/libmcs/libm/complexd/casinhd.c
    • Added double precision complex hyperbolic arc sine function.
  • libm/libmcs/libm/complexd/catand.c
    • Added double precision complex arc tangent function.
  • libm/libmcs/libm/complexd/catanhd.c
    • Added double precision complex hyperbolic arc tangent function.
  • libm/libmcs/libm/complexd/ccosd.c
    • Added double precision complex cosine function.
  • libm/libmcs/libm/complexd/ccoshd.c
    • Added double precision complex hyperbolic cosine function.
  • libm/libmcs/libm/complexd/cexpd.c
    • Added double precision complex exponential function.
  • libm/libmcs/libm/complexd/cimagd.c
    • Added double precision complex imaginary part extraction function.
  • libm/libmcs/libm/complexd/clogd.c
    • Added double precision complex natural logarithm function.
  • libm/libmcs/libm/complexd/conjd.c
    • Added double precision complex conjugate function.
  • libm/libmcs/libm/complexd/cpowd.c
    • Added double precision complex power function.
  • libm/libmcs/libm/complexd/cprojd.c
    • Added double precision complex projection function.
  • libm/libmcs/libm/complexd/creald.c
    • Added double precision complex real part extraction function.
  • libm/libmcs/libm/complexd/csind.c
    • Added double precision complex sine function.
  • libm/libmcs/libm/complexd/csinhd.c
    • Added double precision complex hyperbolic sine function.
  • libm/libmcs/libm/complexd/csqrtd.c
    • Added double precision complex square root function.
  • libm/libmcs/libm/complexd/ctand.c
    • Added double precision complex tangent function.
  • libm/libmcs/libm/complexd/ctanhd.c
    • Added double precision complex hyperbolic tangent function.
  • libm/libmcs/libm/complexd/internal/ctrigd.c
    • Added internal double precision complex trigonometric utility functions.
  • libm/libmcs/libm/complexd/internal/ctrigd.h
    • Added internal double precision complex trigonometric utility header.
  • libm/libmcs/libm/complexf/cabsf.c
    • Added float precision complex absolute value function.
  • libm/libmcs/libm/complexf/cacosf.c
    • Added float precision complex arc cosine function.
  • libm/libmcs/libm/complexf/cacoshf.c
    • Added float precision complex hyperbolic arc cosine function.
  • libm/libmcs/libm/complexf/cargf.c
    • Added float precision complex argument function.
  • libm/libmcs/libm/complexf/casinf.c
    • Added float precision complex arc sine function.
  • libm/libmcs/libm/complexf/casinhf.c
    • Added float precision complex hyperbolic arc sine function.
  • libm/libmcs/libm/complexf/catanf.c
    • Added float precision complex arc tangent function.
  • libm/libmcs/libm/complexf/catanhf.c
    • Added float precision complex hyperbolic arc tangent function.
  • libm/libmcs/libm/complexf/ccosf.c
    • Added float precision complex cosine function.
  • libm/libmcs/libm/complexf/ccoshf.c
    • Added float precision complex hyperbolic cosine function.
  • libm/libmcs/libm/complexf/cexpf.c
    • Added float precision complex exponential function.
  • libm/libmcs/libm/complexf/cimagf.c
    • Added float precision complex imaginary part extraction function.
  • libm/libmcs/libm/complexf/clogf.c
    • Added float precision complex natural logarithm function.
  • libm/libmcs/libm/complexf/conjf.c
    • Added float precision complex conjugate function.
  • libm/libmcs/libm/complexf/cpowf.c
    • Added float precision complex power function.
  • libm/libmcs/libm/complexf/cprojf.c
    • Added float precision complex projection function.
  • libm/libmcs/libm/complexf/crealf.c
    • Added float precision complex real part extraction function.
  • libm/libmcs/libm/complexf/csinf.c
    • Added float precision complex sine function.
  • libm/libmcs/libm/complexf/csinhf.c
    • Added float precision complex hyperbolic sine function.
  • libm/libmcs/libm/complexf/csqrtf.c
    • Added float precision complex square root function.
  • libm/libmcs/libm/complexf/ctanf.c
    • Added float precision complex tangent function.
  • libm/libmcs/libm/complexf/ctanhf.c
    • Added float precision complex hyperbolic tangent function.
  • libm/libmcs/libm/complexf/internal/ctrigf.c
    • Added internal float precision complex trigonometric utility functions.
  • libm/libmcs/libm/complexf/internal/ctrigf.h
    • Added internal float precision complex trigonometric utility header.
  • libm/libmcs/libm/include/complex.h
    • Added new 'complex.h' header for libmcs, including complex number definitions and function prototypes.
  • libm/libmcs/libm/include/fenv.h
    • Added new 'fenv.h' header for libmcs, providing fenv function prototypes (stubs).
  • libm/libmcs/libm/include/internal_config.h
    • Added internal configuration header for libmcs, defining macros for FPU behavior, complex support, and numeric sizes.
  • libm/libmcs/libm/include/math.h
    • Added new 'math.h' header for libmcs, defining math constants, function prototypes, and classification/comparison macros.
  • libm/libmcs/libm/include/numeric_size_config.h
    • Added numeric size configuration header for libmcs, defining macros based on __SIZEOF_DOUBLE__, __SIZEOF_LONG_DOUBLE__, and __SIZEOF_LONG__.
  • libm/libmcs/libm/include/tgmath.h
    • Added new 'tgmath.h' header for libmcs, providing type-generic macros for math functions (with a warning against use in critical systems).
  • libm/libmcs/libm/machine/sparc_v8/mathd/sqrtd.c
    • Added SPARC V8 specific double precision square root implementation using hardware instruction.
  • libm/libmcs/libm/machine/sparc_v8/mathf/sqrtf.c
    • Added SPARC V8 specific float precision square root implementation using hardware instruction.
  • libm/libmcs/libm/mathd/acosd.c
    • Added double precision arc cosine function.
  • libm/libmcs/libm/mathd/acoshd.c
    • Added double precision hyperbolic arc cosine function.
  • libm/libmcs/libm/mathd/asind.c
    • Added double precision arc sine function.
  • libm/libmcs/libm/mathd/asinhd.c
    • Added double precision hyperbolic arc sine function.
  • libm/libmcs/libm/mathd/atan2d.c
    • Added double precision arc tangent of y/x function.
  • libm/libmcs/libm/mathd/atand.c
    • Added double precision arc tangent function.
  • libm/libmcs/libm/mathd/atanhd.c
    • Added double precision hyperbolic arc tangent function.
  • libm/libmcs/libm/mathd/cbrtd.c
    • Added double precision cube root function.
  • libm/libmcs/libm/mathd/ceild.c
    • Added double precision ceiling function.
  • libm/libmcs/libm/mathd/copysignd.c
    • Added double precision copysign function.
  • libm/libmcs/libm/mathd/cosd.c
    • Added double precision cosine function.
  • libm/libmcs/libm/mathd/coshd.c
    • Added double precision hyperbolic cosine function.
  • libm/libmcs/libm/mathd/erfcd.c
    • Added double precision complementary error function.
  • libm/libmcs/libm/mathd/erfd.c
    • Added double precision error function.
  • libm/libmcs/libm/mathd/exp2d.c
    • Added double precision base-2 exponential function.
  • libm/libmcs/libm/mathd/expd.c
    • Added double precision exponential function.
  • libm/libmcs/libm/mathd/expm1d.c
    • Added double precision exponential minus 1 function.
  • libm/libmcs/libm/mathd/fabsd.c
    • Added double precision absolute value function.
  • libm/libmcs/libm/mathd/fdimd.c
    • Added double precision positive difference function.
  • libm/libmcs/libm/mathd/floord.c
    • Added double precision floor function.
  • libm/libmcs/libm/mathd/fmad.c
    • Added double precision fused multiply-add function.
  • libm/libmcs/libm/mathd/fmaxd.c
    • Added double precision maximum function.
  • libm/libmcs/libm/mathd/fmind.c
    • Added double precision minimum function.
  • libm/libmcs/libm/mathd/fmodd.c
    • Added double precision floating-point remainder function.
  • libm/libmcs/libm/mathd/frexpd.c
    • Added double precision frexp function.
  • libm/libmcs/libm/mathd/hypotd.c
    • Added double precision hypotenuse function.
  • libm/libmcs/libm/mathd/ilogbd.c
    • Added double precision integer binary logarithm function.
  • libm/libmcs/libm/mathd/internal/besseld.h
    • Added internal header for Bessel functions, including coefficients and helper functions.
  • libm/libmcs/libm/mathd/internal/errorfunctiond.h
    • Added internal header for error function coefficients and helper functions.
  • libm/libmcs/libm/mathd/internal/fpclassifyd.c
    • Added double precision fpclassify implementation.
  • libm/libmcs/libm/mathd/internal/gammad.c
    • Added internal double precision gamma function utilities.
  • libm/libmcs/libm/mathd/internal/gammad.h
    • Added internal header for gamma function utilities.
  • libm/libmcs/libm/mathd/internal/log1pmfd.h
    • Added internal header for log1p helper function.
  • libm/libmcs/libm/mathd/internal/signbitd.c
    • Added double precision signbit implementation.
  • libm/libmcs/libm/mathd/internal/trigd.c
    • Added internal double precision trigonometric utility functions.
  • libm/libmcs/libm/mathd/internal/trigd.h
    • Added internal header for trigonometric utility functions.
  • libm/libmcs/libm/mathd/j0d.c
    • Added double precision Bessel function of the first kind, order 0.
  • libm/libmcs/libm/mathd/j1d.c
    • Added double precision Bessel function of the first kind, order 1.
  • libm/libmcs/libm/mathd/jnd.c
    • Added double precision Bessel function of the first kind, order n.
  • libm/libmcs/libm/mathd/ldexpd.c
    • Added double precision ldexp function.
  • libm/libmcs/libm/mathd/lgammad.c
    • Added double precision natural logarithm of gamma function.
  • libm/libmcs/libm/mathd/llrintd.c
    • Added double precision nearest integer function (long long int return).
  • libm/libmcs/libm/mathd/llroundd.c
    • Added double precision nearest integer function (long long int return, round half away from zero).
  • libm/libmcs/libm/mathd/log10d.c
    • Added double precision base-10 logarithm function.
  • libm/libmcs/libm/mathd/log1pd.c
    • Added double precision natural logarithm of 1+x function.
  • libm/libmcs/libm/mathd/log2d.c
    • Added double precision base-2 logarithm function.
  • libm/libmcs/libm/mathd/logbd.c
    • Added double precision binary exponent function.
  • libm/libmcs/libm/mathd/logd.c
    • Added double precision natural logarithm function.
  • libm/libmcs/libm/mathd/lrintd.c
    • Added double precision nearest integer function (long int return).
  • libm/libmcs/libm/mathd/lroundd.c
    • Added double precision nearest integer function (long int return, round half away from zero).
  • libm/libmcs/libm/mathd/modfd.c
    • Added double precision modf function.
  • libm/libmcs/libm/mathd/nand.c
    • Added double precision nan function.
  • libm/libmcs/libm/mathd/nearbyintd.c
    • Added double precision nearbyint function.
  • libm/libmcs/libm/mathd/nextafterd.c
    • Added double precision nextafter function.
  • libm/libmcs/libm/mathd/nexttowardd.c
    • Added double precision nexttoward function.
  • libm/libmcs/libm/mathd/powd.c
    • Added double precision power function.
  • libm/libmcs/libm/mathd/remainderd.c
    • Added double precision remainder function.
  • libm/libmcs/libm/mathd/remquod.c
    • Added double precision remquo function.
  • libm/libmcs/libm/mathd/rintd.c
    • Added double precision rint function.
  • libm/libmcs/libm/mathd/roundd.c
    • Added double precision round function.
  • libm/libmcs/libm/mathd/scalblnd.c
    • Added double precision scalbln function.
  • libm/libmcs/libm/mathd/scalbnd.c
    • Added double precision scalbn function.
  • libm/libmcs/libm/mathd/sind.c
    • Added double precision sine function.
  • libm/libmcs/libm/mathd/sinhd.c
    • Added double precision hyperbolic sine function.
  • libm/libmcs/libm/mathd/sqrtd.c
    • Added double precision square root function.
  • libm/libmcs/libm/mathd/tand.c
    • Added double precision tangent function.
  • libm/libmcs/libm/mathd/tanhd.c
    • Added double precision hyperbolic tangent function.
  • libm/libmcs/libm/mathd/tgammad.c
    • Added double precision tgamma function.
  • libm/libmcs/libm/mathd/truncd.c
    • Added double precision trunc function.
  • libm/libmcs/libm/mathd/y0d.c
    • Added double precision Bessel function of the second kind, order 0.
  • libm/libmcs/libm/mathd/y1d.c
    • Added double precision Bessel function of the second kind, order 1.
  • libm/libmcs/libm/mathd/ynd.c
    • Added double precision Bessel function of the second kind, order n.
  • libm/libmcs/libm/mathf/acosf.c
    • Added float precision arc cosine function.
  • libm/libmcs/libm/mathf/acoshf.c
    • Added float precision hyperbolic arc cosine function.
  • libm/libmcs/libm/mathf/asinf.c
    • Added float precision arc sine function.
  • libm/libmcs/libm/mathf/asinhf.c
    • Added float precision hyperbolic arc sine function.
  • libm/libmcs/libm/mathf/atan2f.c
    • Added float precision arc tangent of y/x function.
  • libm/libmcs/libm/mathf/atanf.c
    • Added float precision arc tangent function.
  • libm/libmcs/libm/mathf/atanhf.c
    • Added float precision hyperbolic arc tangent function.
  • libm/libmcs/libm/mathf/cbrtf.c
    • Added float precision cube root function.
  • libm/libmcs/libm/mathf/ceillf.c
    • Added float precision ceiling function.
  • libm/libmcs/libm/mathf/copysignf.c
    • Added float precision copysign function.
  • libm/libmcs/libm/mathf/cosf.c
    • Added float precision cosine function.
  • libm/libmcs/libm/mathf/coshf.c
    • Added float precision hyperbolic cosine function.
  • libm/libmcs/libm/mathf/erfcf.c
    • Added float precision complementary error function.
  • libm/libmcs/libm/mathf/erff.c
    • Added float precision error function.
  • libm/phoenix/common.h
    • Renamed 'math/common.h' to 'libm/phoenix/common.h'.
  • libm/phoenix/complex.c
    • Renamed 'math/complex.c' to 'libm/phoenix/complex.c'.
  • libm/phoenix/exp.c
    • Renamed 'math/exp.c' to 'libm/phoenix/exp.c'.
  • libm/phoenix/hyper.c
    • Renamed 'math/hyper.c' to 'libm/phoenix/hyper.c'.
  • libm/phoenix/power.c
    • Renamed 'math/power.c' to 'libm/phoenix/power.c'.
  • libm/phoenix/trig.c
    • Renamed 'math/trig.c' to 'libm/phoenix/trig.c'.
Activity
  • The pull request was created by ayoopierre.
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the libmcs math library (v1.3.0) as an alternative implementation for critical systems and refactors the existing libphoenix math implementation into a separate directory. It also removes the math library dependency from strtod.c. The changes include a new libm/Makefile to select between implementations and a configure script for libmcs. My review identified a few critical logic errors in the libm/Makefile and the libphoenix implementation, as well as a syntax bug in the configure script.

libm/Makefile Outdated
LIBM_WANT_COMPLEX ?= y

# Set options for denormals on the FPU
ifeq ($(LIBMCS_WANT_DAZ), y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a variable name mismatch here. The variable defined on line 12 is LIBM_LIBMCS_DAZ, but this check uses LIBMCS_WANT_DAZ. This will cause the LIBMCS_FPU_DAZ flag to never be set correctly based on the user's choice.

ifeq ($(LIBM_LIBMCS_DAZ), y)

while true
do
if [ -z ${extra_cflags+x} ]; then read -r extra_cflags; fi
if $($CC -c ${sizecheck} ${extra_cflags}); then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The use of $() here is incorrect. It will attempt to execute the output of the compiler command as a shell command. Since a successful compilation typically produces no output to stdout, this will result in a shell syntax error. It should simply execute the command and check its exit status.

	if $CC -c ${sizecheck} ${extra_cflags}; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant